﻿@model SAIM.Models.NewTicketsViewModel
@{
    ViewBag.Title = "Nuevo ticket";
}
@section css {
@Styles.Render("~/Content/bootstrap-select")
@Styles.Render("~/Content/typeahead")
}

<h2>@ViewBag.Title</h2>
@Html.ValidationSummary("", new { @class = "text-danger" })
@using (Html.BeginForm("New", "Tickets", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
    @Html.AntiForgeryToken()
    <hr />
    if (Model.Users.Count() > 0)
    {
        <input class="invisible" data-val="true" data-val-required="Ningún usuario seleccionado" id="User" name="User" value="" type="text">
        <div class="form-group">
            @Html.LabelFor(m => m.User, new { @class = "col-sm-2 control-label" })
            <div class="col-sm-10">
                <input type="text" class="form-control typeahead saim-sm-2" placeholder="Buscar..." autocomplete="off" />
                <span class="text-danger field-validation-error" data-valmsg-for="User" data-valmsg-replace="true"></span>
            </div>
        </div>
    }
    <div class="form-group">
        @Html.LabelFor(m => m.Area, new { @class = "col-md-2 col-sm-2 control-label" })
        <div class="col-md-10 col-sm-10">
            @Html.DropDownListFor(m => m.Area, Model.Areas, new { @class = "form-control saim-sm-2 selectpicker", @id = "Areas-DropDown" })
            @Html.ValidationMessageFor(m => m.Area, "", new { @class = "text-danger" })
        </div>
    </div>
    <div id="Issues" class="form-group"></div>
    <div class="form-group">
        @Html.LabelFor(m => m.Details, new { @class = "col-md-2 col-sm-2 control-label" })
        <div class="col-md-10 col-sm-10">
            @Html.TextAreaFor(m => m.Details, new { @class = "form-control saim-sm-2 saim-textarea", @rows = "7" })
            @Html.ValidationMessageFor(m => m.Details, "", new { @class = "text-danger" })
        </div>
    </div>
    <div class="form-group">
        <div class="col-md-offset-2 col-sm-offset-2 col-md-10 col-sm-10">
            <input type="submit" class="btn btn-default" value="Crear" />
        </div>
    </div>
}

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/bootstrap-select")
@Scripts.Render("~/bundles/typeahead")
<script type="text/javascript">
    urlIssues = "@Url.Action("_GetIssues", "Tickets")";
    urlUsers = '@Url.Action("GetTypeaheadUsers", "Users")/?id=%QUERY';
</script>

<script type="text/javascript" src="@Url.Content("~/Scripts/Tickets/NewTicket.js")"></script>
}
